package com.shangxia.spr.controller;

import com.shangxia.common.vo.ResultVO;
import com.shangxia.spr.enums.npc.BaseNpcEnum;
import com.shangxia.spr.enums.npc.NpcStateEnum;
import com.shangxia.spr.enums.npc.NpcTypeEnum;
import com.shangxia.spr.mapper.dao.BaseNpcInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zhouya38158
 * @date 2021/11/30 16:49
 * @apiNote 角色
 */
@Slf4j
@RestController
@RequestMapping("/role")
@Api("角色")
public class RoleController {

    @GetMapping("/list")
    @ApiOperation(notes = "角色列表", value = "增加属性")
    public ResultVO<List<BaseNpcInfo>> listRoles() {
        List<BaseNpcInfo> result = Arrays.stream(BaseNpcEnum.values()).map(BaseNpcEnum::getBaseNpcInfo)
                .filter(e -> NpcTypeEnum.ROLE.equals(e.getNpcType()))
                .filter(e -> NpcStateEnum.ACTIVE.equals(e.getNpcState()))
                .collect(Collectors.toList());
        return ResultVO.okResultVO(result);
    }
}
